package cn.dida.service.impl;

import cn.dida.dao.SalesmanPayruleDao;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;

/**
 * Created by zhangzhiling on 2017/9/4.
 */
@Service("QuartzService")
public class QuartzService {

    private Log loger = LogFactory.getLog(QuartzService.class);

    @Autowired
    private SalesmanPayruleDao payruleDao;

    public void salesmanPayruleSate(){
        Calendar c = Calendar.getInstance();
        String now = DateFormatUtils.format(c, "yyyy-MM-dd HH:mm:ss");
        loger.info("***updateStart***start***开始执行今天的定时任务。date="+ now);
         Integer count = payruleDao.updateStateByQuartz();

        if (count == 0) {
            loger.info("******end***结束执行今天的定时任务。没有查询出需要结束的结算规则");
        } else {
            loger.info("******end***结束执行今天的定时任务。共更新 "+ count +"条结算规则。");
        }
    }
}
